//
//  PresentVC.swift
//  WBSwift
//
//  Created by maker on 2016/11/10.
//  Copyright © 2016年 maker. All rights reserved.
//

import UIKit

class PresentVC: UIPresentationController {
    lazy var maskView : UIView = UIView()
    var transFrame : CGRect = CGRect.zero
    override func containerViewWillLayoutSubviews() {
        presentedView?.frame = transFrame
        setMaskView()
    }

}

//MARK:==========设置 UI==========
extension PresentVC{
    func setMaskView() {
        //设置蒙版属性
        maskView.backgroundColor = UIColor(white: 0.8, alpha: 0.2)
        maskView.frame = containerView!.bounds
        
        //给蒙版添加手势
        let tapGesture = UITapGestureRecognizer(target: self, action: #selector(PresentVC.tapClick))
        maskView .addGestureRecognizer(tapGesture)
        containerView?.insertSubview(maskView, at: 0)
    }
}

//MARK:==========监听事件==========

extension PresentVC{
    func tapClick() {
        presentedViewController .dismiss(animated: true, completion: nil)
    }
}






